<!--
  Licensed to the Apache Software Foundation (ASF) under one
  or more contributor license agreements.  See the NOTICE file
  distributed with this work for additional information
  regarding copyright ownership.  The ASF licenses this file
  to you under the Apache License, Version 2.0 (the
  "License"); you may not use this file except in compliance
  with the License.  You may obtain a copy of the License at

      http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.
  -->
<div class="box box-primary">
	<div class="box-header with-border">
		<i class="fa fa-list-alt"> </i>
		<h3 class="box-title">
			{{dataSource.desc || dataSource.tags.dataSource || "All Policies"}}
			<div class="btn-group">
				<button class="btn btn-box-tool dropdown-toggle" data-toggle="dropdown" aria-expanded="false">
					<i class="fa fa-caret-down"></i>
				</button>
				<ul id="programList" class="dropdown-menu" role="menu">
					<li ng-repeat="dataSrc in site.current().dataSrcList" ng-hide="dataSrc.hide">
						<a href="#/dam/policyList/{{dataSrc.tags.dataSource}}">{{dataSrc.desc || dataSrc.tags.dataSource}}</a>
					</li>
					<li class="divider"></li>
					<li>
						<a href="#/dam/policyList">All Policy List</a>
					</li>
				</ul>
			</div>
		</h3>
	</div>
	<div class="box-body">
		<div class="row">
			<div class="col-xs-3">
				<div class="search-box">
					<input type="search" class="form-control input-sm" placeholder="Search" ng-model="search" />
					<span class="fa fa-search"> </span>
				</div>
			</div>
			<div class="col-xs-6">
				<div class="inline-group form-inline text-muted">
					<dl><dt><i class="fa fa-square text-green"> </i></dt><dd>Enabled</dd></dl>
					<dl><dt><i class="fa fa-square text-muted"> </i></dt><dd>Disabled</dd></dl>
				</div>
			</div>
			<div class="col-xs-3 text-right">
				<a class="btn btn-primary" href="#/dam/policyCreate/{{!dataSource ? '' : '?dataSrc=' + dataSource.tags.dataSource}}" ng-show="auth.isRole('ROLE_ADMIN')">
					New Policy
					<i class="fa fa-plus-circle"> </i>
				</a>
			</div>
		</div>

		<p ng-show="policyList._promise.$$state.status !== 1">
			<span class="fa fa-refresh fa-spin"> </span>
			Loading...
		</p>

		<div sorttable source="policyList" ng-show="policyList._promise.$$state.status === 1" search="false" searchfunc="searchFunc">
			<table class="table table-bordered" ng-non-bindable>
				<thead>
					<tr>
						<th width="30" sortpath="enabled"> </th>
						<th width="200" sortpath="tags.policyId">Policy Name</th>
						<th sortpath="desc">Description</th>
						<th width="150" sortpath="owner">Owner</th>
						<th width="170" sortpath="lastModifiedDate">Last Modified</th>
						<th width="95" ng-show="_parent.auth.isRole('ROLE_ADMIN')">Action</th>
					</tr>
				</thead>
				<tbody>
					<tr>
						<td><span class='fa fa-square' ng-class="item.enabled ? 'text-green' : 'text-muted'"> </span></td>
						<td><a href="#/dam/policyDetail/{{item.encodedRowkey}}">{{item.tags.policyId}}</a></td>
						<td>{{item.desc}}</td>
						<td>{{item.owner}}</td>
						<td>{{common.format.date(item.lastModifiedDate) || "-"}}</td>
						<td ng-show="_parent.auth.isRole('ROLE_ADMIN')">
							<a class="fa fa-pencil btn btn-default btn-xs" tooltip="Edit" tooltip-animation="false" href="#/dam/policyEdit/{{item.encodedRowkey}}"> </a>
							<button class="fa fa-play sm btn btn-default btn-xs" tooltip="Enable" tooltip-animation="false" ng-show="!item.enabled" ng-click="_parent.updatePolicyStatus(item, true)"> </button>
							<button class="fa fa-pause sm btn btn-default btn-xs" tooltip="Disable" tooltip-animation="false" ng-show="item.enabled" ng-click="_parent.updatePolicyStatus(item, false)"> </button>
							<button class="rm fa fa-trash-o btn btn-danger btn-xs" tooltip="Delete" tooltip-animation="false" ng-click="_parent.deletePolicy(item)"> </button>
						</td>
					</tr>
				</tbody>
			</table>
		</div>
	</div>
	<!--div class="box-footer clearfix">
	</div-->
</div>
